package com.swinginwind.flexutils.components
{
	import flash.display.DisplayObject;
	import flash.utils.Dictionary;
	
	import mx.controls.Image;
	import mx.core.IFlexDisplayObject;
	import mx.managers.PopUpManager;

	/**
	 * @author jimmy
	 * @E-mail: swinginwind@gmail.com
	 * @version 1.0.0
	 * 创建时间：2013-4-23 下午2:08:57
	 * 
	 */
	public class WaitingEffect
	{
		
		public static var dic:Dictionary;
		
		[Embed(source='/com/swinginwind/flexutils/assets/icons/progressCircle.swf#progressCircle')] 
		public static var _maskIcon:Class;
		
		private var image:Image;
		
		public function WaitingEffect()
		{
		}
		
		public function show(parent:DisplayObject=null):void {
			image = new Image();
			image.source = _maskIcon;
			PopUpManager.addPopUp(image, parent);
			PopUpManager.centerPopUp(image);
		}
		
		public function hide():void {
			if(image)
				PopUpManager.removePopUp(image);
		}
		
		public static function show2(parent:DisplayObject=null, modal:Boolean = false):void {
			if(!dic)
				dic = new Dictionary();
			var image2:Image = new Image();
			image2.source = _maskIcon;
			PopUpManager.addPopUp(image2, parent, modal);
			PopUpManager.centerPopUp(image2);
			dic[parent] = image2;
		}
		
		public static function hide2(parent:DisplayObject=null):void
		{
			if(dic && dic[parent])
			{
				PopUpManager.removePopUp(dic[parent]);
				delete dic[parent];
			}
		}
		
	}
}